//
//  OMOrderRefundListTableCell.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/5/22.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMOrderRefundListTableCell.h"
#import "OMRefund.h"
#import "OMOrder.h"

#import "OMRefund.h"
#import "NSString+AttributedString.h"
#import "NSAttributedString+SizeRemind.h"
#import <YYText.h>
@interface OMOrderRefundListTableCell ()
@property (nonatomic, strong) UILabel *refundPriceLabel;
@property (nonatomic, strong) UILabel *requestTimeLabel;
@property (nonatomic, strong) UILabel *goodInfoLabel;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UILabel *numberLabel;
@end

@implementation OMOrderRefundListTableCell

- (void)configure
{
    [super configure];

    _refundPriceLabel = [UILabel new];
    _refundPriceLabel.font = SM_CFont(30);
    _refundPriceLabel.textColor = SM_blackColor;
    [self.contentView addSubview:_refundPriceLabel];
    [_refundPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(30)));
        make.top.equalTo(@(SM_SIZE(30)));
    }];

    _requestTimeLabel = [UILabel new];
    _requestTimeLabel.font = SM_CFont(30);
    _requestTimeLabel.textColor = SM_darkGrayColor;
    [self.contentView addSubview:_requestTimeLabel];
    [_requestTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_refundPriceLabel.mas_left);
        make.top.equalTo(_refundPriceLabel.mas_bottom).offset(SM_SIZE(20));
    }];

    _goodInfoLabel = [UILabel new];
    _goodInfoLabel.textColor = SM_darkGrayColor;
    _goodInfoLabel.font = SM_CFont(30);
    _goodInfoLabel.numberOfLines = 0;
    [self.contentView addSubview:_goodInfoLabel];
    [_goodInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(30)));
        make.top.equalTo(self.requestTimeLabel.mas_bottom).offset(SM_SIZE(20));
        make.right.equalTo(@(SM_SIZE(-30)));
//        make.bottom.equalTo(@(SM_SIZE(-30)));
    }];

    _statusLabel = [UILabel new];
    _statusLabel.font = SM_CFont(28);
    _statusLabel.textColor = SM_thumeColor;
    [self.contentView addSubview:_statusLabel];
    [_statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(SM_SIZE(-30)));
        make.top.equalTo(@(SM_SIZE(30)));
    }];
}


- (void)configureCellWithObj:(OMRefund *)refund
{
    NSMutableAttributedString *price = [[NSMutableAttributedString alloc]initWithString:@"退款金额："];
    [price appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"￥%.2f",refund.amount.floatValue] attributes:@{NSForegroundColorAttributeName:SM_redColor}]];
    self.refundPriceLabel.attributedText = price;

    self.statusLabel.text = refund.order.statusName;
    self.requestTimeLabel.text = [NSString stringWithFormat:@"申请时间：%@",refund.create_date];
    NSAttributedString *good = [[NSString stringWithFormat:@"商品信息：%@",refund.order.desc] attributedStringWithColor:SM_darkGrayColor font:SM_CFont(30) lineSpace:SM_SIZE(10)];
    self.goodInfoLabel.attributedText = good;
}


+ (CGFloat)cellHeightWithObj:(OMRefund *)refund
{
     NSAttributedString *good = [[NSString stringWithFormat:@"商品信息：%@",refund.order.desc] attributedStringWithColor:SM_darkGrayColor font:SM_CFont(30) lineSpace:SM_SIZE(10)];
    return [good boundSize:CGSizeMake(SM_SCREEN_WIDTH-SM_SIZE(30)*2, CGFLOAT_MAX)].height+SM_SIZE(170);
}

@end
